program define fx1_byparty
   version 15.1
   syntax varlist [if] [pweight], t1(varname) [OPTS(str) ALLFIVE BYOPTS(str)]
	marksample touse
	if "`weight'" ~= "" {
	   local wt [`weight'`exp']
   }	
	tempname fx1 fx2 fx3
   forvalues p = 1/3 {
	   di _n(2) "** Party `p' **"
      fx1 `varlist' if `touse' & pid3==`p' `wt', t1(`t1') `allfive' nodraw
      mat `fx`p'' = r(fx)
   }
	* combine 3 plots horizontally
	local gopts scheme(s1mono) plotregion(style(none)) mlabel format(%3.0f)
   coefplot (matrix(`fx1'[1,]), ci("`fx1'[5,] `fx1'[6,]") msymbol(O) mlabpos(10)), bylabel(Democrats) ///
	   ||  ///
		(matrix(`fx2'[1,]), ci("`fx2'[5,] `fx2'[6,]") msymbol(O) mlabpos(10)), bylabel(Independents) ///
		|| ///
		(matrix(`fx3'[1,]), ci("`fx3'[5,] `fx3'[6,]") msymbol(O) mlabpos(10)), bylabel(Republicans) ///
		coeflabel(none = "No Action" low = "Cut 5%" high = "Cut 25%" /// cover all possible labels
		   c0="No Action" c1="Cut 5%, Cost 10%" c2="Cut 5%, Cost 4%" ///
         c3="Cut 25%, Cost 10%" c4="Cut 25%, Cost 4%") ///
		byopts(rows(1) legend(off) `byopts') subtitle(, fcolor(white)) `gopts' `opts'
end
